<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../js/vue.js"></script>
</head>

<body>
  <div id="app">
    <my-com>
      <template v-slot:header="scope">
        {{scope}}
        我是头部内容
      </template>
      <template v-slot:default>
        <p>hello component</p>
        <h3>你好组件插槽</h3>
      </template>
      <template v-slot:footer>
        我是脚步内容
      </template>
    </my-com>
  </div>
  <script>
    // 定义组件
    let component = {
      data() {
        return {
          comData: 'hello slot'
        }
      },
      template: `
        <div>
          <header>
            <slot v-bind:msg="comData" name="header"></slot>
          </header>
          <main>
            <slot name="default"></slot>
          </main>
          <footer>
            <slot name="footer"></slot>
          </footer>
        </div>
      `
    }

    let vm = new Vue({
      el: "#app",
      data: {

      },
      methods: {

      },
      created() {

      },
      components: {
        myCom: component
      }
    })
  </script>
</body>

</html>